﻿namespace ${project}
{
    public class Url
    {
		private static string __ParseUrl__(string __url__)
        {
            switch (__url__)
            {
				${set(rewriteFileList=rewriteData.rewriteFileList)}
				${foreach(rewriteFile in rewriteFileList)}
				case "${rewriteFile.to}":__url__ = "${rewriteFile.from}"; break;
				${end}
				default: break;
            }
			${set(rewriteDirectoryList=rewriteData.rewriteDirectoryList)}
			${foreach(rewriteDirectory in rewriteDirectoryList)}
			if(__url__.StartsWith("${rewriteDirectory.to}"))
			{
				__url__ = "${rewriteDirectory.from}" + __url__.Remove(0,"${rewriteDirectory.to}".Length);
			}
			${end}
            return __url__;
        }
        ${set(i=1)}
		${foreach(fileData in controllerFileDataList)}
		${set(fileDataClassDataList=fileData.ClassDataList)}
		${foreach(classData in fileDataClassDataList)}
		${set(classDataMethodDataList=classData.MethodDataList)}
		${foreach(methodData in classDataMethodDataList)}
        ${if(methodData.isPublic)}
		${methodData.CommitString}
		public static string ${fileData.appName}_${classData.name}_${methodData.name}(${methodData.urlParser.formatParameterTypeAndNames})
        {
            string __url__=string.Format("${methodData.urlParser.formatUrl}"${methodData.urlParser.formatParameters});
			__url__ = __ParseUrl__(__url__);
            return __url__;
        }
		${set(i=i+1)}
		${end}
		${end}
		${end}
		${end}
    }
}
